from django.db import models
from django.contrib.auth.models import AbstractUser


class User(AbstractUser):
    """自定义用户模型类"""
    mobile = models.CharField(max_length=11, unique=True, verbose_name='手机号')
    img_url = models.ImageField(verbose_name='图片url', default="//q2apgq6sj.bkt.clouddn.com/200.png")

    gender = models.BooleanField(default=False, verbose_name="用户性别")
    description = models.TextField(default="来描述一下自己吧", verbose_name="用户自我描述")

    class Meta:
        db_table = 'bk_users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username


class User_book(models.Model):
    """用户书架"""
    user = models.ForeignKey(User, verbose_name='用户外键')
    book = models.ForeignKey("book.Book", verbose_name='小说外键')
    book_info = models.ForeignKey("book.Book_Info", verbose_name='小说阅读进度章节', default="尚未阅读")
    is_del = models.BooleanField(verbose_name="逻辑删除", default=False)

    class Meta:
        db_table = 'bk_users_book'
        verbose_name = '书架'
        verbose_name_plural = verbose_name
